package cqrtplm.controller;

import com.alibaba.fastjson.JSONObject;
import com.ty.basic.response.ResponseResult;
import cqrtplm.constant.RouteConstant;
import cqrtplm.dto.DesignDerivationDTO;
import cqrtplm.dto.PartFeatureDTO;
import cqrtplm.service.RTPartService;
import cqrtplm.vo.PartFeatureVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "物料")
@RequestMapping(RouteConstant.PART + "v1")
public class RTPartController {

    @Resource
    private RTPartService rtPartService;

    @PostMapping("/getPartIba")
    @ApiOperation(value = "getPartIba",notes = "查询物料特征")
    @ResponseBody
    public PartFeatureDTO getPartIba(@RequestBody PartFeatureVO vo){
        return rtPartService.getPartIba(vo);
    }

    @GetMapping("/verifyDesignDerivation")
    @ApiOperation(value = "verifyDesignDerivation",notes = "校验设计衍生")
    public DesignDerivationDTO verifyDesignDerivation(String drawingCode){
        return rtPartService.verifyDesignDerivation(drawingCode);
    }

    @PostMapping("/checkPartIfExistPublishVersion")
    @ApiOperation(value = "verifyDesignDerivation",notes = "校验零件是否存在已生效版本")
    public ResponseResult checkPartIfExistPublishVersion(@RequestBody List<JSONObject> params){
        rtPartService.checkPartIfExistPublishVersion(params);
        return ResponseResult.success();
    }
}
